import request from '@/utils/request'

const baseURL = '/admin/seckillProduct'

// 获取秒杀商品列表
export const getSeckillProductList = () => {
    return request.post(`${baseURL}/list`)
}

// 添加秒杀商品
export const addSeckillProduct = (data) => {
    return request.post(`${baseURL}/add`, data)
}

// 更新秒杀商品
export const updateSeckillProduct = (data) => {
    return request.post(`${baseURL}/update`, data)
}

// 删除秒杀商品
export const deleteSeckillProduct = (id) => {
    return request.post(`${baseURL}/delete`, null, {
        params: { id }
    })
}

// 获取秒杀商品详情
export const getSeckillProductDetail = (id) => {
    return request.get(`${baseURL}/detail/${id}`)
}

// 上传秒杀商品图片
export const uploadSeckillProductImage = (file, id) => {
    const formData = new FormData()
    formData.append('files', file)
    if (id) {
        formData.append('id', id)
    }
    return request.post(`${baseURL}/upload/seckillProduct`, formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 上架/下架秒杀商品
export const updateSeckillProductStatus = (id) => {
    return request.post(`${baseURL}/status`, null, {
        params: { id }
    })
} 